package com.zhaolulu.util;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.nio.file.Paths;

/**
 * @Description: 代码生成工具
 */
public class CodeGenerator {
    public static void main(String[] args) {
        String url = "jdbc:mysql://192.168.100.168:3306/cache_db?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true";
        String username = "root";
        String password = "heima123";
        String path = "F:\\SoftData\\DevStudio\\seata\\web-std";
        FastAutoGenerator.create(url, username, password)
                .globalConfig(builder -> builder
                        .author("火飞鹰")
                        .outputDir(Paths.get(path, "src", "main", "java").toString())
                        .commentDate("yyyy-MM-dd")
                )
                .packageConfig(builder -> builder
                        .parent("com.zhaolulu")
                        .entity("domain")
                        .mapper("mapper")
                        .service("service")
                        .serviceImpl("service.impl")
                        .xml("mapper.xml")
                )
                .strategyConfig(builder -> builder
                        .entityBuilder()
                        .enableLombok()
                )
                .templateEngine(new FreemarkerTemplateEngine())
                .execute();
    }
}
